package 枚举_引用;

import java.util.Scanner;

public class UseEnumDemo {
    // 获取所有枚举，看看枚举实例有哪些方法
    public static void main(String[] args) {
        for(Category category: Category.values()){
            System.out.println("---------------------");
            System.out.println("category.getId()\t"+category.getId());
            System.out.println("category.ordinal()\t"+category.ordinal());  // ordinal--依次的
            System.out.println("category.name()\t"+category.name());
            System.out.println(""+category.toString());
            System.out.println();
        }

        System.out.println("=========根据名字获取字段=========");
        System.out.println(Category.valueOf("FOOD"));



       Scanner in = new Scanner(System.in);
        System.out.println("请输入枚举的名字：");
        String categoryName = in.nextLine();
        Category enumInput = Category.valueOf(categoryName.trim().toUpperCase());
        System.out.println("枚举的信息:\t" + enumInput);

        System.out.println("请输出要比较的枚举的名字：");
        String categoryName2 = in.next();
        Category enumInput2 = Category.valueOf(categoryName2.trim().toUpperCase());
        System.out.println(enumInput == enumInput2);
    }
}
